{{- define "main" -}}

{{- .Scratch.Set "Widgets" (slice "search" "tree") -}}
{{- .Scratch.Set "Active" (dict "Menu" (.Params.menu | default "/docs/")) -}}

<div class="LBody">
    <div class="Side">
        {{- template "header" . -}}
        {{- partial "Side/widgets.html" . -}}
        {{- partial "Side/footer.html" . -}}
    </div>
    <div class="Main">
        {{- partial "mobile-only.html" . -}}
        <div class="content markdown">
            <h1 class="title">{{ .Title }}</h1>
            <span class="description">{{ .Description }}</span>
            {{- partial "func/content.html" . -}}
            {{- template "card" . -}}
        </div>
    </div>
</div>

{{- end -}}

{{- define "header" -}}
{{- $section := index (last 1 (where .Ancestors "Section" "docs")) 0 -}}
{{- $root := index $section.Data.Pages 0 -}}
<header class="header">
    <a class="back" href="{{ $root.Parent.Permalink }}">
        <svg aria-hidden="true" viewBox="0 0 16 16" width="1rem" height="1rem" fill="currentColor">
            <path fill-rule="evenodd" d="M7.78 12.53a.75.75 0 01-1.06 0L2.47 8.28a.75.75 0 010-1.06l4.25-4.25a.75.75 0 011.06 1.06L4.81 7h7.44a.75.75 0 010 1.5H4.81l2.97 2.97a.75.75 0 010 1.06z"></path>
        </svg>
        <span>所有项目</span>
    </a>
    <div class="info">
        <a class="title" href="{{ $root.Permalink }}">
            <h1 class="text">{{ $root.Title }}</h1>
        </a>
    </div>
</header>
{{- end -}}

{{- define "card" -}}
<div class="cards">
    {{- $section := index (last 1 (where .Ancestors "Section" "docs")) 0 -}}
    {{- $root := index $section.Data.Pages 0 -}}
    {{- range .Data.Pages -}}
        <a class="card" href="{{ .Permalink }}">
            <span class="title">{{ .Title }}</span>
            <span class="link">:{{ substr .Permalink (sub (len $root.Permalink) 1) }}</span>
        </a>
    {{- end -}}
    </div>
    <placeholder></placeholder>
{{- end -}}